<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/form2json.js"></script>
    <script>

        function sub() {

            $.ajax({
                //请求路径
                url: "/user/login",
                //请求参数
                data: $("#f01").formToJson(),
                //请求方式
                type: "POST",
                //数据响应格式
                dataType: "JSON",
                //成功 操作


                statusCode:{
                    204:function () {
                        alert("登录成功")

                        location.href = "/html/list.html";
                    },
                    500:function () {
                        alert("登录失败,用户名或密码错误")

                    }

                }


            })
        }
    </script>
</head>
<body>

<form action="" id="f01">


    <table  width="500px">

        <tr>
            <td>登录名</td>
            <td>
                <input type="text" name="loginName">
            </td>
        </tr>

        <tr>
            <td>密码</td>
            <td>
                <input type="text" name="loginPwd">
            </td>
        </tr>


        <tr>
            <td></td>
            <td>
                <input type="button"  onclick="sub()" value="登录">
            </td>
        </tr>


    </table>
    
</form>

</body>
</html>